package org.soft.xinyu.equipmentmanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.soft.xinyu.equipmentmanagement.entity.MachineFile;
import org.soft.xinyu.equipmentmanagement.mapper.MachineFileMapper;
import org.soft.xinyu.equipmentmanagement.service.MachineFileService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author vicente
 * @since 2021-11-22
 */
@Service
public class MachineFileServiceImpl extends ServiceImpl<MachineFileMapper, MachineFile> implements MachineFileService {

    @Autowired
    private MachineFileMapper machineFileMapper;

    @Override
    public Object uploadMachineFile() {
        return null;
    }

    @Override
    public Boolean deleteMachineFileById(MachineFile machineFile) {
        //删除文件

        //删除记录
        machineFileMapper.deleteById(machineFile.getId());
        return true;
    }

    @Override
    public Boolean deleteMachineFileByMachineId(String machineId) {
        List<MachineFile> machineFileList = machineFileMapper.selectList(new QueryWrapper<MachineFile>().eq("machine_id", machineId));
        for (MachineFile machineFile : machineFileList) {
            //删除文件

            //删除记录
            machineFileMapper.deleteById(machineFile.getId());
        }
        return true;
    }
}
